<div class="findtrs" >
	<form action="" class="layui-inline layui-form" method="post" style="width: 100%;">
		<div class="ftitle">
			<div class="lt">
				<h2>HT支付</h2>
			</div>
		</div>
		<div class="fremittanpred fbai" style="height: 740px" >
			<div class="txt">
				<p>完成支付操作后，会自动跳转到充值界面。</p>
				{if $error_msg != ''}
				<p style="color: red;font-size: 20px;">Error : {$error_msg}。</p>
				{/if}
			</div>
			<div class="list">
				<ul>
					<li>
						<label style="font-size: 20px;font-weight: bold">充值金额 : <i>$ {$money}</i></label>

						<input type="hidden" id="out_trade_no" value="{$out_trade_no}">
					</li>
					{if $error_msg == ''}
					<li><label style="font-size: 20px;font-weight: bold">订单 : <i>{$out_trade_no}</i></label></li>
					{/if}
				</ul>
				<ul>
					<li>
						<label style="font-size: 20px;font-weight: bold">扫码金额 : <i>$ {$real_money}</i></label>
					</li>
					<li>
						<label style="font-size: 20px;font-weight: bold">支付方式 : <i>{if $pay_type == 'alipay'}支付宝{else}微信{/if}</i></label><br/>
					</li>
				</ul>
				<ul>
					{if $error_msg == ''}
					<li>
						<img id="zfb_show" src="{$qr_code}" alt="" style="height: 200px;width: 200px;padding-left: 100px;">
					</li>
					{/if}
				</ul>
			</div>
			<div class="list">
				{if $error_msg == ''}
				<ul>
					<li style="font-size: 20px;padding-left: 50px;">
						请在:
						<strong id="hour_show"><s id="h"></s>0时</strong>
						<strong id="minute_show"><s></s>00分</strong>
						<strong id="second_show"><s></s>00秒</strong>
						内完成支付
					</li>
				</ul>
				{/if}
			</div>
			<div class="fbottonlst" style="float: left">
				<ul>
					<li><a href="{:url('fund/htpay')}">返回</a></li>
				</ul>
			</div>
		</div>
	</form>

</div>
<script type="text/javascript">
	var myTimer;
	var intDiff=1;
	$(document).ready(function() {
		index = setInterval("ajaxstatus()", 2000);
	});
	function ajaxstatus() {
		if(intDiff>0){
			var date = new Date();
			var timer = date.getTime().toString();
			$.ajax({
				url:"{:url('checkHtpay')}?mcard=" + $('#out_trade_no').val() + "&t=" + timer,
				type: "GET",
				dataType: "json",
				success: function(res) {
					console.log(res.data.check);
					const check = res.data.check;
					if(check == 1) { //订单状态为1表示支付成功
						layer.msg('支付成功.' , {time:1500});
						window.location.href = "{:url('log')}";
					}
					if(check == 2) { //订单状态为1表示支付成功
						layer.msg('支付失败，请稍后再尝试.' , {time:2000});
						window.location.href = "{:url('htpay')}";
					}
				},
				error: function() {

				}
			});
		}
	}
	function timer(intDiff) {
		myTimer = window.setInterval(function () {
			var day = 0,
					hour = 0,
					minute = 0,
					second = 0;//时间默认值
			if (intDiff > 0) {
				day = Math.floor(intDiff / (60 * 60 * 24));
				hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
				minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
				second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
			}
			if (minute <= 9) minute = '0' + minute;
			if (second <= 9) second = '0' + second;
			$('#hour_show').html('<s id="h"></s>' + hour + '时');
			$('#minute_show').html('<s></s>' + minute + '分');
			$('#second_show').html('<s></s>' + second + '秒');
			if (hour <= 0 && minute <= 0 && second <= 0) {
				intDiff = 0;
				window.location.href = "{:url('msjpay')}";
				clearInterval(myTimer);
			}
			intDiff--;

		}, 2000);
	}
	$().ready(function() {
		timer("300");
	});
</script>